﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Osteox.ManagedCv;
using System.Threading;

namespace WinFormSample
{
    static class Program
    {
        const string FILENAME = "Filters.settings"; 
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            CvException.TurnRaiseException(true);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            Application.ApplicationExit += new EventHandler(OnApplicationExit);
            SampleProperty property = SampleProperty.Current;
            try
            {
                property.Load(FILENAME);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Application.Run(new MainForm());
        }

        static void OnApplicationExit(object sender, EventArgs e)
        {
            SampleProperty property = SampleProperty.Current;
            property.Save(FILENAME);
        }

        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            MessageBox.Show(e.Exception.ToString());
        }
    }
}
